const express = require('express')

const app = express()

//request是对请求报文的封装，respose是对响应报文的封装
app.get('/serve', (request, response) => {
  //设置响应头,设置允许跨域
  response.setHeader('Access-Control-Allow-Origin', '*')
  //设置响应体
  response.send('hello ajax')
})

app.post('/serve', (request, response) => {
  //设置响应头,设置允许跨域
  response.setHeader('Access-Control-Allow-Origin', '*')
  //设置响应体
  response.send('hello ajax post')
})
//监听端口
app.listen(3000, () => {
  console.log('服务已启动')
})